<?php
	session_start();
	header("Content-Type: text/html;charset=utf-8");
	$conn = mysqli_connect('8.129.105.38','db_lsp','123456');
	if($conn){
		$select = mysqli_select_db($conn,"db_lsp");		
		if($select){

			if(isset($_POST["remake"])){
				
				$user = $_POST["username"];
				$phone =$_POST["phone"];
				$email =$_POST["email"];
				$password = $_POST["password"];
				$repassword =$_POST["repassword"];

				
				if($user == ""||$password == ""||$phone == ""||$email == ""||$repassword == ""){
					echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."请填写完整！"."\"".")".";"."</script>";
					echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."重置密码_teacher.html"."\""."</script>";
					exit;
				}
				$sql_select = "select teacher_id,teacher_email,teacher_tel from t_db_user where teacher_id = '$user'";
				mysqli_query($conn,'SET NAMES UTF8');
				$ret = mysqli_query($conn,$sql_select);
				$row = mysqli_fetch_array($ret); 
				$_SESSION[classification]="teacher";
				if($user == $row['teacher_id']&&$phone == $row['teacher_tel']&&$email == $row['teacher_email']){
					if($password==$repassword)
					{
						$sql="update t_db_user set teacher_pwd='$password'";
						$ret = mysqli_query($conn,$sql);
						
						echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."修改成功"."\"".")".";"."</script>";
						echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."登录_teacher.html"."\""."</script>";
					}
					else{
						echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."两次密码不一样"."\"".")".";"."</script>";
						echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."重置密码_teacher.html"."\""."</script>";
					}
					
					
				}else{
					echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."填写信息错误！"."\"".")".";"."</script>";
					echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."重置密码_teacher.html"."\""."</script>";
					exit;
				}  
			}
		}
		mysqli_close($conn);
	}else{		
		die('Could not connect:'.mysql_error());
	}	
 ?>
